<include file="public@header"/>
<style type="text/css">

    .p_title {
        width: 515px;
        margin: 0 0 45px 60px;
        padding: 10px 0 10px 20px;
    }
    tr td input,tr td select{ max-width:100%;width:auto;}
    .content_nav .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}

    .form-control{
        width:100%; display:inline-block;
    }
    .free .form-group{
        margin-top: 30px;}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('finance/index')}">财务管理</a></li>
        <li class="active"><a href="{:url('Aftersale/orderPay')}?order_id={$order_id}">订单支付</a></li>
    </ul>
    <form class="form-horizontal  " action="{:url('finance/orderPay')}" method="post" enctype="multipart/form-data">
        <fieldset>
            <!--改版画面-->
            <div class="div_title"><span>客户概览</span></div>
            <div class="control-group1-p div_content">
                <div class="form-group">
                    <label class="control-label w100">客户姓名</label>
                    <div class="col-lg-2"   >
                        <input type="text"  class="form-control" value="{$customer.buyer_name}" disabled>
                    </div>
                    <label class="control-label w100">持证类型</label>
                    <div class="col-lg-2" >
                        <input type="text" class="form-control" value="{:cart_type('cart',$customer.cart_type)}" disabled>
                    </div>
                    <label class="control-label w100">证件号码</label>
                    <div class="col-lg-2"  >
                        <input type="text"  class="form-control" value="{$customer.customer_account}" disabled>
                    </div>
                    <label class="control-label w100"  >联系电话</label>
                    <div class="col-lg-2" >
                        <input type="text"  class="form-control" value="{$customer.buyer_phone}" disabled>
                    </div>
                </div>

                <div class="form-group" >
                    <label class="control-label w100">联系地址</label>
                    <div class="col-lg-6" style="width: 41%;" >
                        <input type="text"   class="form-control" value="{$customer.customer_address}" disabled>
                    </div>
                    <label class="control-label w100">合同编号</label>
                    <div class="col-lg-2"  >
                        <input type="text" name="user_login" class="form-control" value="{$result.contract_sn}" disabled>
                    </div>
                    <label class="control-label w100">墓位编号</label>
                    <div class="col-lg-2"  >
                        <input type="text" name="user_login" class="form-control" value="{$result.tomb_num}" disabled>
                    </div>
                </div>
                <div class="form-group" >
                    <label class="control-label w100">具体位置</label>
                    <div class="col-lg-2" style="width: 41%;">
                        <input type="text" name="user_login" class="form-control" value="{$result.tomb_region}" disabled>
                    </div>
                    <label class="control-label w100">当前状态</label>
                    <div class="col-lg-2" >
                        <input type="text" name="user_login" class="form-control" value="{$result.pro_status}" disabled>
                    </div>
                    <label class="control-label w100" >格位规制</label>
                    <div class="col-lg-2"  >
                        <input type="text" name="user_login" class="form-control" value="双穴" disabled>
                    </div>
                </div>

                <div class="row" style="margin: 0;padding: 0;" >
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-12" style="padding: 0 5px 10px 10px;">
                                <div class="box box-info">
                                    <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                        <div class="div_title" ><span>交款记录</span></div>
                                    </div>

                                    <div class="box-body" style="padding-top:0; height: 225px; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                        <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                            <thead>
                                            <tr>
                                                <th>寄存单号</th>
                                                <th>类型</th>
                                                <th>付/退款人姓名</th>
                                                <th>付/退款人时间</th>
                                                <th>金额</th>
                                                <th>付/退款人方式</th>
                                                <th>经办人</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <foreach name="deposit" item="vo">
                                                <tr>
                                                    <td >{$vo.pay_sn}</td>
                                                    <td >
                                                        <!--<if condition="$vo.type eq 1"> 定金-->
                                                            <!--<if condition="$vo.status eq 0"> -->定金
                                                            <!--<elseif condition="$vo.status eq 2" />  -->退金
                                                            <!--</if>-->
                                                        <!--</if>--> </td>
                                                    <td >{$vo.real_name}</td>
                                                    <td >{$vo.add_time|date='Y-m-d H:i:s'}</td>
                                                    <td >{$vo.deposit_price}</td>
                                                    <td >{:cart_type('pay',$vo.pay_type)}</td>
                                                    <td >{:cmf_get_admin_name($vo.pay_real_name)}</td>
                                                </tr>
                                            </foreach>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 free">
                        <div class="box box-info">
                            <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                <div class="div_title" ><span>费用信息</span></div>
                            </div>
                            <div class="box-body" style="padding-top:0; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                <div class="form-group" >
                                    <label class="control-label">购墓价格</label>
                                    <div class="col-lg-3"  >
                                        <input type="hidden" name="tomb_num" class="selling_price" value="{$result.tomb_num}">
                                        <input type="hidden" name="tom_price" class="selling_price" value="{$result.selling_price}">
                                        <input type="text"  class="form-control selling_price" value="{$result.selling_price}" disabled>
                                    </div>
                                    <label class="control-label">优惠折扣</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text" id="discount_ratio"    disabled class="form-control" >
                                        <input type="hidden" id="discount_ratio_" name="discount_rate" value="{$pay_info.discount_rate}" >
                                    </div>
                                </div>
                                <div class="form-group" >

                                    <label class="control-label"style="">免零金额</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text" name="free_price" class="form-control free_price" value="{$pay_info.free_price}" >
                                    </div>
                                    <label class="control-label">成交付款</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="hidden"  class="closing_price" name="deal_price"  value="{$pay_info.deal_price}" >
                                        <input type="text"  class="form-control closing_price_"  value="￥{$pay_info.deal_price}" disabled>
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">已付定金</label>
                                    <div class="col-lg-3" style="">
                                        <input type="hidden" class="deposit_price"  name="deposit_price" value="{$pay_info.deposit_price}" >
                                        <input type="text"  class="form-control deposit_price_"  value="￥{$pay_info.deposit_price}" disabled>
                                    </div>
                                    <label class="control-label">应收金额</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="hidden" class="total_price"  name="total_price" value="{$pay_info.total_price} " >
                                        <input type="text"  class="form-control total_price_"   disabled>
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">付款人</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text"  name="real_name" class="form-control"  value="{$pay_info.real_name}">
                                    </div>
                                    <label class="control-label">付款人联系电话</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text"  name="real_phone" class="form-control"  value="{$pay_info.real_phone}">
                                    </div>
                                </div>
                                <div style="float:left; width:80%; margin-left:6%;border-bottom:1px dashed;margin-bottom:20px;"></div>
                                <div class="form-group" >
                                    <label class="control-label">商品总计</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="hidden" class="goods_price" name="goods_price"  value="0">
                                        <input type="text" class="form-control goods_price_"  value="￥0" disabled>
                                    </div>

                                    <label class="control-label">付款方式</label>
                                    <div class="col-lg-3" style=" ">
                                        <select name="pay_type"   class="form-control">
                                            <option value="1">现金</option>
                                            <option value="2">转账</option>
                                            <option value="3">电汇</option>
                                            <option value="4">微信</option>
                                            <option value="5">支付宝</option>
                                            <option value="6">其他</option>
                                        </select>
                                    </div>
                                </div>
                                <div style="float:left; width:80%; margin-left:6%;border-bottom:1px dashed;margin-bottom:20px;"></div>

                                <div class="form-group" >
                                    <label class="control-label">收银备注</label>
                                    <div class="col-lg-7" style=" ">
                                        <textarea rows="3" name="remark" class="form-control" ></textarea>
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">付款时间</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text" name="add_time" class="form-control js-date"  value='{$result.payaddtime}' autocomplete="off">
                                    </div>
                                    <label class="control-label">收款人</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text" name="user_login" class="form-control"  value="{:cmf_get_admin_name()}" disabled>
                                    </div>
                                </div>

                                <div class="form-group" >
                                    <div class="col-lg-12" style=" ">
                                        <label class="control-label"> </label>
                                        <input type="hidden" name="pay_id"   value="{$pay_info.id}">
                                        <input type="hidden" name="tomb_type"   value="1">
                                        <input type="hidden" name="dtype" id="otype" value="4">
                                        <input type="hidden" name="order_id" value="{$result.order_id|default=''}">
                                        <input type="hidden" name="tomb_id" value="{$result.tomb_id|default=''}">
                                        <input type="hidden" name="tomb_num" value="{$result.tomb_num|default=''}">
                                        <input type="hidden" name="customer_id" value="{$result.customer_id|default=''}">

                                        <a href="{:url('PrintSettlement')}?order_id={$result.order_id}&pay_id={$pay_info.id}" target="_blank" class="btn btn-primary" id="Print_statement">打印结算单</a>
                                        <a href="{:url('Stamp/print_cert')}?order_id={$result.order_id}&pay_id={$pay_info.id}&type=6" target="_blank" class="btn btn-primary" id="Print_statement">打印定金数据</a>
                                        <div class="btn btn-primary" id="Refund">退款</div>
                                        <div class="btn btn-primary" id="settlement">结账</div>
                                        <!--<if condition="$pay_info.status eq 0">-->
                                            <div class="btn btn-primary check-save" data-index="refund">退款</div>
                                            <div class="btn btn-primary check-save" data-index="settlement">结账</div>
                                        <!--</if>-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript">
    $(function () {
        // $('select[name=pay_type]').val('{$pay_info.pay_type}')
        // $('#discount_ratio').val($('#discount_ratio_').val()+'折')
        // var receivable_price = Number(Number($('.closing_price').val().replace(/,/g, "")).toFixed(2)*1 -
        //     Number($('.free_price').val().replace(/,/g,"")).toFixed(2)*1 -
        //     Number($('.deposit_price').val().replace(/,/g,"")).toFixed(2)*1);
        // $('.total_price').val(receivable_price)
        // $('.total_price_').val('￥'+receivable_price)
    });
    $('.free_price').blur(function () {
        var receivable_price = Number(Number($('.closing_price').val().replace(/,/g, "")).toFixed(2)*1 -
            Number($('.free_price').val().replace(/,/g,"")).toFixed(2)*1 -
            Number($('.deposit_price').val().replace(/,/g,"")).toFixed(2)*1);
        $('.total_price').val(receivable_price)
        $('.total_price_').val('￥'+receivable_price)

    })
    //' 提交保存
    $("#check-save").click(function(){
        $("#otype").val(1);
        $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            if(result.code == 1){
                alert("保存成功！");
                window.location.href = result.url;
            } else {
                alert(result.code);
            }
        }, 'json');
    });
    // 打印结算单
    $("#Print_statement").click(function(){
        $("#otype").val(2);
        $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            if(result.state == 'success'){
                alert("保存成功！");
                $('#js-dialog-close').click();
            } else {
                alert(result.info);
            }
        }, 'json');
    });
    // 退款
    $("#Refund").click(function(){
        $("#otype").val(3);
        $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
            if(result.state == 'success'){
                alert("保存成功！");
                $('#js-dialog-close').click();
            } else {
                alert(result.info);
            }
        }, 'json');
    });
    // 结账
    $("#settlement").click(function(){
        $("#otype").val(4);
        $.post($(".form-horizontal").attr('.form-horizontal'), $("form").serialize(), function(result){
            if(result.code == 1){
                window.location.href = result.url;
            } else {

            }
        }, 'json');
    });
    $("#div_title").click(function(){
        if($(".div_titleinfo").is(":hidden")){
            $(".div_titleinfo").show();
        }else{
            $(".div_titleinfo").hide();
        }
    })
    $("#div_title1").click(function(){
        if($(".div_titleinfo1").is(":hidden")){
            //
            $(".div_titleinfo1").show();
        }else{
            $(".div_titleinfo1").hide();
        }
    })
</script>
</body>
</html>